package com.jiazhong.boot.exception.service.impl;

import com.jiazhong.boot.commons.util.JsonResult;
import com.jiazhong.boot.commons.util.ResultTool;
import com.jiazhong.boot.exception.handler.LoginFailException;
import com.jiazhong.boot.exception.service.FirstService;
import org.springframework.stereotype.Service;

@Service
public class FirstServiceImpl implements FirstService {

    @Override
    public JsonResult a() {
        return ResultTool.success("aaa");
    }

    @Override
    public JsonResult b(int num) {
        int result = 9 / num;
        return ResultTool.success(result);
    }

    @Override
    public JsonResult login(String username, String password) {
        if (!("admin".equals(username) && "123456".equals(password))) {
            // 是不是就是错误的信息
            throw new LoginFailException("账号或者密码错误");
            // return  ResultTool.fail(401, "<UNK>");
        }
        return ResultTool.success("success");
    }
}
